/**
 * 
 */
	var oTable;

	$(function() {
		$("#downbtn").click(download);
		
		oTable = $('#table_report').dataTable( {
			"sDom" : '<"wrapper"lrtf<"row-fluid"<"span6"i><"span6"p>>>',
	        //"bRetrieve" : true,
	        //"bStateSave": true,
	        "bPaginate" : true, 
	        "fnServerData": retrieveData,
	        
	        "bAutowidth" : true,
            "iDisplayLength" : 10,  
            "bScrollCollapse" : false,  
            //"bInfo" : true,   
            "bSort" : false,   
            "bFilter" : false,   
            "bLengthChange": false,
            "oLanguage": DATATABLE_CN,
            
	        "bDestroy" : true, 
	        "sServerMethod": "POST",
	        "fnInitComplete": function(oSettings, json) {
	        	setHeight()
	        },
			
			"bProcessing": false,
	        "bServerSide": true,
	        "aoColumns": [
				{ "mData": "logintime",  "sClass": "center" , "mRender": mTimeFormat },
	            { "mData": "chargetime" ,  "sClass": "center", "mRender": mTimeFormat },
	            { "mData": "endtime" ,  "sClass": "center", "mRender": mTimeFormat },
	            { "mData": "duration" ,  "sClass": "center", "mRender": function(data, type, object){
	            	return data?data:"";
	            } },
	            { "mData": "optcode" ,  "sClass": "center" , "mRender": function(data, type, object){
	            	return optMap[data]?optMap[data]:data;
	            } },
	            { "mData": "status" ,  "sClass": "center" , "mRender": function(data, type, object){
	            	var ret;
	            	switch (data){
		            	case "0" : ret="登录"; break;
		            	case "1" : ret="上网中"; break;
		            	case "2" : ret="上网完毕"; break;
		            	default: ret = data;
	            	}
	            	return ret;
	            } }
	        ],
	        "sAjaxSource": "../userdetail"
			});
		
		$('[data-rel=tooltip]').tooltip();
		
		function retrieveData(sSource, aoData, fnCallback){
			aoData.push({"name": "userid",
				 "value": userid});
			aoData = $.demonPlugin.collectFormData(aoData);
			$.demonPlugin.asyncData("POST" , sSource, aoData, fnCallback);
		}
		
		$("#cancel").click(function(){
			window.history.back();
		});
		
	});
	
	function download(){
		$("#userid").val(userid);
		$("#download").attr("action", "../download");
		$("#download").submit();
	}